package org.builder.service;

import org.dynobjects.core.BeanCreator;
import org.dynobjects.core.EPClassLoader;
import org.dynobjects.core.RuntimeCompiler;

public class DynamicObjectsFactoryService {

	private RuntimeCompiler runtimeCompiler;

	private BeanCreator beanCreator;

	public RuntimeCompiler getRuntimeCompiler() {
		return runtimeCompiler;
	}

	public void setRuntimeCompiler(RuntimeCompiler runtimeCompiler) {
		this.runtimeCompiler = runtimeCompiler;
	}

	public BeanCreator getBeanCreator() {
		return beanCreator;
	}

	public void setBeanCreator(
			BeanCreator dynamicObjectsFactory) {
		this.beanCreator = dynamicObjectsFactory;
	}

	
	public void compile() throws Exception{
		
		runtimeCompiler.compile(getBeanCreator());
		
	}
	
	public Object getInstance(String className) throws InstantiationException, IllegalAccessException, ClassNotFoundException{
		return new EPClassLoader().get(className).newInstance();
	}
}
